
function colseDiv() {
    $("#qiandao_wrap").remove();
}
$(function () {
    //导航
    $("#phone_nav_btn").click(function () {
        var num = $("#phone_nav").data("num");
        if (num == 0) {
            $("#phone_nav").slideDown();
            $("#phone_nav").data("num", 1);
        } else {
            $("#phone_nav").slideUp();
            $("#phone_nav").data("num", 0);
        }
    });
    LoadSignIn(0);
});

function LoadSignIn(value)//签到
{
    $.ajax({
        url: "/PersonalCenter/UserSignIn",//
        data: { value: value },
        type: "post",
        dataType: "json",
        success: function (data) {
            if (data.Success) {
                if (data.Obj.IsNo == 0) {
                    var res = "<div id=\"qiandao_wrap\">" +
                                "<div id=\"qiandao\">" +
                                    "<a class=\"closeBtn\" href=\"javascript:colseDiv();\"></a>" +
                                    "<h3>连续签到 " + data.Obj.user_CheckNum + " 天</h3>" +
                                    "<ul class=\"clearfix\">" +
                                        "<li>" +
                                            "<i>" + data.Obj.oneMoney + "</i>" +
                                            "<p>第1天</p>" +
                                        "</li>" +
                                        "<li>" +
                                            "<i>" + data.Obj.twoMoney + "</i>" +
                                            "<p>第2天</p>" +
                                        "</li>" +
                                        "<li>" +
                                            "<i>" + data.Obj.threeMoney + "</i>" +
                                            "<p>第3天</p>" +
                                        "</li>" +
                                        "<li>" +
                                            "<i>" + data.Obj.fourMoney + "</i>" +
                                            "<p>第4天</p>" +
                                        "</li>" +
                                        "<li class=\"ml\">" +
                                            "<i>" + data.Obj.fiveMoney + "</i>" +
                                            "<p>第5天</p>" +
                                        "</li>" +
                                        "<li>" +
                                            "<i>" + data.Obj.sixMoney + "</i>" +
                                            "<p>第6天</p>" +
                                        "</li>" +
                                        "<li>" +
                                            "<i>" + data.Obj.sevenMoney + "</i>" +
                                            "<p>第7天</p>" +
                                        "</li>" +
                                    "</ul>" +
                                    "<a href=\"javascript:SignInUser();\" class=\"button\">签 到</a>" +
                                "</div>" +
                            "</div>";
                    $("body").append(res);
                    if (data.Obj.user_CheckNum > 0) {
                        $("#qiandao ul li:lt(" + data.Obj.user_CheckNum + ")").addClass("open");
                    }
                }
                else {
                    if (value == 1) {
                        $.messager.alert('提示:', data.Msg, "info");
                    }
                }
            }
            else {
                if (value == 1) {
                    $.messager.alert('提示:', data.Msg, "info");
                }
            }
        }
    });
}

function SignInUser()//绑卡
{
    $.ajax({
        url: "/PersonalCenter/SignInMoney",//
        type: "post",
        dataType: "json",
        success: function (data) {
            if (data.Success) {
                $("#qiandao ul li:lt(" + data.Obj + ")").addClass("open");
                setTimeout(onBind, 2000);
            } else {
                $('#qiandao_wrap').remove();
                if (data.Obj == 10) {
                    $.messager.alert('提示:', data.Msg, "error", function () {
                        location.href = "/PersonalCenter/BankAdd";
                    });
                }
                else {
                    $.messager.alert('提示:', data.Msg, "error");
                }
            }
        }
    });
}

function onBind() {
    $('#qiandao_wrap').remove();
    location.href = "/PersonalCenter";
}

